<%@page import="com.wu24.bean.*,com.wu24.service.*,java.util.*,com.wu24.util.*"%>
<%@ page language="java" pageEncoding="utf-8"%>
<!DOCTYPE HTML>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/font-awesome.min.css">
    <link rel="stylesheet" href="css/owl.carousel.css">
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="css/responsive.css">
 </head>
<body>
<div class="header-area">
        <div class="container">
            <div class="row">
                <div class="col-md-8">
                    <div class="user-menu">
                        <ul>
                            <li><a href="#"><i class="fa fa-user"></i>欢迎<%=((User)session.getAttribute("user")).getUserName() %>登录</a></li>  
                        </ul>
                    </div>                     
                </div>
            </div>
        </div>
    </div> <!-- End header area -->
    
    <div class="site-branding-area">
        <div class="container">
            <div class="row">
                <div class="col-sm-6">
                    <div class="logo">
                        <h1><a href="index.html"><span>西北大学二手交易市场</span></a></h1>
                    </div>
                </div>
                
              <div class="col-sm-6">
                <p>&nbsp;</p>
                  <p>&nbsp;</p>
                <p>寻你所想 如你所愿
                </p>
              </div>
            </div>
        </div>
    </div> <!-- End site branding area -->
    
    <div class="mainmenu-area">
        <div class="container">
            <div class="row">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                </div> 
                <div class="navbar-collapse collapse">
                    <ul class="nav navbar-nav">
                         <li><a href="main.jsp">首页</a></li>
                        <li ><a href="shop.jsp">逛一逛</a></li>                
                        <li><a href="cart.jsp">购物车</a></li>
                        <li><a href="upload.jsp">上传商品</a></li>
                          <li class="active"><a href="singleProduct.jsp">商品详情</a></li>       
                        
                        
                    </ul>
                </div>  
            </div>
        </div>
    </div> <!-- End mainmenu area -->


    
    <div class="product-big-title-area">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <div class="product-bit-title text-center">
                        <h2>不知你 有没有心动</h2>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    
    <div class="single-product-area">
        <div class="zigzag-bottom"></div>
        <div class="container">
            <div class="row">
                <div class="col-md-4">
                    <div class="single-sidebar">
                        <h2 class="sidebar-title">寻你所想 找你想要</h2>
                        <form action="type.jsp">
                            <input type="text"  name="key" placeholder="输入你想要的商品">
                            <input type="hidden" name="type" value="7"> 
                            <input type="submit" value="搜索">
                        </form>
                    </div>
                    
                    <div class="single-sidebar">
                        <h2 class="sidebar-title">热门商品</h2>
                      
                       <%
                       List<String>ids=CommentService.getHotGood(3);
					    List<Good>hotGoods=new ArrayList<Good>();
					    for(String id:ids){
					    	hotGoods.add(GoodsService.getGoodById(id));
					    }
					    for(Good good:hotGoods){ 
                       
                       %>                     
                        <div class="thubmnail-recent">
                           <a href="singleProduct.jsp?id=<%=good.getGoodId()%>"> <img src="<%=good.getPhotoPath() %>" class="recent-thumb" alt=""></a>
                            <h2><a href="singleProduct.jsp?id=<%=good.getGoodId()%>"><%=good.getName() %></a></h2>
                            <div class="product-sidebar-price">
                            <ins><%=good.getPrice() %>元</ins></div>                             
                        </div>
                       <%
					    }
                       %>        
                    </div>
                    
                    <div class="single-sidebar">
                        <h2 class="sidebar-title">&nbsp;</h2>
                        <ul>
                            <li></li>
                        </ul>
                    </div>
                </div>
                <% 
                    Good goods=GoodsService.getGoodById(request.getParameter("id"));
                    User seller=UserService.getUserbyId(goods.getUserId());
                    
                %>
                <div class="col-md-8">
                    <div class="product-content-right">
                        <div class="product-breadcroumb"></div>
                        
                        <div class="row">
                            <div class="col-sm-6">
                                <div class="product-images">
                                    <div class="product-main-img" >
                                        <p>&nbsp;</p>
                                        <p>&nbsp;</p>
                                        <p>&nbsp;</p>
                                        <p><img src=<%=goods.getPhotoPath()%> alt=""></p>
                                        
                                    </div> 
                                </div>
                            </div>
                            
                            <div class="col-sm-6">
                                <div class="product-inner">
                                    <h2 align="center" class="product-name"><%=goods.getName() %></h2>
                                    <div align="center" class="product-inner-price">
                                    <ins><%=goods.getPrice() %>元</ins>
                                    </div>                                                                 
                                    <form  align="center" action="trolleyHandler" class="cart">          
                                        <input  type="hidden"  name="type" value="add">
                                        <input type="hidden"    name="id"   value="<%=goods.getGoodId() %>">               
                                        <button class="add_to_cart_button" type="submit">加入购物车</button>
                                    </form>                               
                                  <div role="tabpanel">
                                        <ul class="product-tab" role="tablist">
                                            <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">商品详情</a></li>
                                            <li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">联系卖家</a></li>
                                         <li role="presentation"><a href="#comment" aria-controls="profile" role="tab" data-toggle="tab">添加评论</a></li>
                                            
                                        </ul>
                                        <div class="tab-content">
                                            <div role="tabpanel" class="tab-pane fade in active" id="home">
                                                <h2>            </h2> 
                                                <p>&nbsp;</p> 
                                                <p><%=goods.getDescription() %></p>
                                                <p>&nbsp;</p>
                                                <p>&nbsp;</p>
                                                <p>&nbsp;</p>
                                                <p>&nbsp;</p>
                                                <p>&nbsp;</p>
                                                <p>&nbsp;</p>
                                                <p>&nbsp;</p>
                                                <p>&nbsp;</p>
                                            </div>
                                            <div role="tabpanel" class="tab-pane fade" id="profile">
                                                <div class="submit-review">
                                                    <p>卖家:<%=seller.getUserName() %></p>
                                                    <p>电话号码:<%=seller.getPhone() %></p>
                                                    <p>QQ号:<%=seller.getQq() %></p>
                                                </div>
                                            </div>
                                            <div role="tabpanel" class="tab-pane fade" id="comment">
                                                <div class="submit-review">
                                                 <form action="commentHanlder" method="post">                                                   
                                                  <textarea rows="3" cols="20" name="content"></textarea>
                                                     <input type="submit"  value="提交"/>
                                                     <input type="hidden" name="goodId" value="<%=goods.getGoodId() %>">                                                  
                                                     </form> 
                                                </div>
                                            </div>
                                        </div>
                                  </div>
                                    
                                </div>
                            </div>
                        </div>                     
                    </div>                                     
                </div>                             
            </div>                    
        </div>   
        <%
        int commentCount=CommentService.getCommentCount(goods.getGoodId());
        if(commentCount>0){
        %>            
        <h2  style="padding:0px 500px"  class="related-products-title">评论</h2>    
        <%    
        int pageNow=1;
        int pageSize=3; 
        if(request.getParameter("pageNow")!=null){
        
       	 pageNow=Integer.parseInt(request.getParameter("pageNow"));   
       }   
        List<Comment>comments=CommentService.getCommentById(pageNow, pageSize,goods.getGoodId());
        for(Comment comment:comments){   
           
        %> 
              <div style="padding:0px 500px">
        <hr>                                        
        <p style="color:#1abc9c"><%=UserService.getUserbyId(comment.getUserId()).getUserName() %>:<p>                     
        <p><%=MarketUtil.getTime(comment.getDate()) %><p>                 
        <p><%=comment.getComment() %></p>     
        </div>         
        <%
          }
        %>
                        
            <div class="row">
                <div class="col-md-12">
                    <div class="product-pagination text-center">
                        <nav>
                          <ul class="pagination">
                            <li>
                               <%                              
                               int pageCount=(CommentService.getCommentCount(goods.getGoodId())+pageSize-1)/pageSize;
                                int previous;
                               if(pageNow==1){
                            	   previous=pageCount;
                               }
                               else{
                            	   previous=pageNow-1;
                               }
                               String url="singleProduct.jsp?id="+goods.getGoodId()+"&pageNow="+previous;
                               %>
                              <a href="<%=url %>">
                                <span>&laquo;</span>
                              </a>
                            </li>
                            <%       
                            int start=pageNow;
                            int end=pageNow+3;
                            if(end>=pageCount){                           	
                            	end=pageCount;                  
                            }
                            for(int i=start;i<=end;i++){
                           url="singleProduct.jsp?id="+goods.getGoodId()+"&pageNow="+i;
                            %>
                             <li><a href=<%=url %>><%=i%></a></li>                       
                            <%
                              }
                            %>
                         
                            <li>
                            <%     
                            int next;
                            if(pageNow==pageCount){
                            	next=1;                             	
                            }
                            else{
                            	next=pageNow+1;                           	
                            }
                          url="singleProduct.jsp?id="+goods.getGoodId()+"&pageNow="+next;
                            %>
                              <a href=<%=url%>>
                                <span>&raquo;</span>
                              </a>
                            </li>
                          </ul>
                        </nav>                        
                    </div>
                </div>
            </div>
            <%
            }
            %>
           
    </div>
<div class="footer-top-area">
        <div class="zigzag-bottom"></div>
        <div class="container">
            <div class="row">
                <div class="col-md-3 col-sm-6">
                    <div class="footer-about-us">
                        <h2>声明<span></span></h2>
                        <p>本网站仅做测试使用，如有侵权，请联系我们。</p>
             
                    </div>
                </div>
                
                <div class="col-md-3 col-sm-6">
                    <div class="footer-menu">
                        <h2 align="center" class="footer-wid-title">如果不满意</h2>
                        <ul><li>
                          <div align="center"><a href="">淘宝</a></div>
                        </li>
                            <li>
                              <div align="center"><a href="">苏宁易购</a></div>
                            </li>
                            <li>
                              <div align="center"><a href="">58同城</a></div>
                            </li>
                            <li>
                              <div align="center"><a href="">转转</a></div>
                            </li>
                            <li>
                              <div align="center"><a href="">唯品会</a></div>
                            </li>
                        </ul>                        
                  </div>
                </div>
                
                <div class="col-md-3 col-sm-6">
                    <div class="footer-menu">
                        <h2 align="center" class="footer-wid-title">请点击这里</h2>
                    <ul>
                            <li>
                              <div align="center"><a href="">淘宝</a></div>
                        </li>
                          <li>
                            <div align="center"><a href="">京东</a></div>
                      </li>
                          <li>
                            <div align="center"><a href="">天猫</a></div>
                      </li>
                          <li>
                            <div align="center">蘑菇街<a href=""></a></div>
                          </li>
                        <li>
                              <div align="center"><a href="">赶集网</a></div>
                        </li>
                      </ul>                        
                    </div>
                </div>
                
                <div class="col-md-3 col-sm-6">
                    <div class="footer-newsletter">
                        <h2 align="center" class="footer-wid-title">或者联系我们</h2>
                      <p>如果你对我们的工作不满意，请输入您的建议</p>
                        <div class="newsletter-form">
                            <input type="email" placeholder="请输入您的建议">
                            <input type="submit" value="提交">
                        </div>
                    </div>
                </div>
            </div>
        </div>
</div>
  
   
   
   
</body>
</html>
    <!-- Latest jQuery form server -->
<script src="js/jquery-1.8.3.min.js"></script>
    
    <!-- Bootstrap JS form CDN -->
<script src="js/bootstrap.min.js"></script>
    
    <!-- jQuery sticky menu -->
<script src="js/owl.carousel.min.js"></script>
<script src="js/jquery.sticky.js"></script>
    
    <!-- jQuery easing -->
<script src="js/jquery.easing.1.3.min.js"></script>
    
    <!-- Main Script -->
<script src="js/main.js"></script>
  </body>
</html>